package com.tyut.config;


import com.tyut.vo.ResultJson;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

@RestControllerAdvice
public class DefaultException {

    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public ResultJson handleMaxUploadSizeExceeded(MaxUploadSizeExceededException e) {
        e.printStackTrace();
        return ResultJson.failed("文件大小超出限制");
    }


    @ExceptionHandler
    public ResultJson defaultExceptionHandler(Exception e) {
        e.printStackTrace();
        return ResultJson.failed("系统异常");
    }

    @ExceptionHandler(UserException.class)
    public ResultJson UserExistExceptionHandler(UserException e) {
        e.printStackTrace();
        return ResultJson.failed(e.getMessage());
    }


}

